home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / Imaging & Layout / Adding a Facet < prev    next >
Encoding:
Text File  |  1995-07-10  |  2.7 KB  |  76 lines  |  [TEXT/ttxt]

  1. OpenDoc™ Recipes
  2.  
  3.  
  4. Adding and Removing Facets
  5. By The OpenDoc Design Team
  6. 19 April, 1994
  7.  
  8.  
  9. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  10. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  11. Mac and OpenDoc are trademarks of Apple Computer, Inc.  (Palatino/10/Plain)
  12.                                                                                                                                                                                                                         
  13.  
  14. Adding a Facet
  15.  
  16. Parts are notified when a facet is added to a display frame.
  17.  
  18.                                                                     void FacetAdded(in ODFacet facet)
  19.  
  20. As when a display frame is added to a part, the part must take actions to handle the addition of a new facet to one of its display frames. Some of these actions are dependent on the nature of the part, but some are fairly standard. These are:
  21.  
  22. •    Create facets for embedded frames. If there are embedded frames that should be visible within the new facet, the part should make them visible using the “Making a Frame Visible” recipe.
  23.  
  24. •    Add partInfo to the facet. PartInfo is stored in facets less often than in frames, but the option is available to help parts distinguish different facets. The part may also use partInfo to store graphics-system-related information used for displaying that facet. If a part does want to store partInfo in its facets, it should be added when the facet is added to the part.
  25.  
  26. MyPartFacetAdded(Environment* ev, MyPart* somSelf, ODFacet* facet)
  27. {
  28.  
  29.  ODFrame* frame = facet->AcquireFrame(ev);
  30.     ODEmbeddedFramesIterator iter = somSelf->CreateEmbeddedFramesIterator(ev, frame);
  31.  frame->Release(ev);
  32.  
  33.     for (ODFrame* embedded = iter->First(ev);
  34.             iter->IsNotComplete(ev);
  35.             embedded = iter->Next(ev))
  36.     {
  37.         if ( /* check to see if embedded frame is visible */ )
  38.         {
  39.  
  40.             // set up new facet geometry...
  41.             childFacet = facet->CreateEmbeddedFacet(ev, embedded, ... );
  42.             // set up partInfo...
  43.             childFacet->SetPartInfo(ev, (ODInfoType)partInfo);
  44.         }
  45.     }
  46.     delete iter;
  47. }
  48.  
  49. Removing a Facet
  50.  
  51. Parts are also notified when a facet is removed from a display frame.
  52.  
  53.                                                                     void FacetRemoved(in ODFacet facet)
  54.  
  55. The part must handle the removal of facets from its display frames. The actions the part needs to perform to do this will depend on what it did when the facet was added. Typically the part should:
  56.  
  57. •    Remove facets for embedded frames.
  58.  
  59. •    Remove partInfo from the facet.
  60.  
  61. MyPartFacetRemoved(Environment* ev, MyPart* somSelf, ODFacet* facet)
  62. {
  63.     ODFacetIterator iter = facet->CreateFacetIterator(ev,
  64.                                                 kODChildrenOnly, kODFrontToBack);
  65.     for (ODFacet* childFacet = iter->First(ev);
  66.             iter->IsNotComplete(ev);
  67.             childFacet = iter->Next(ev))
  68.     {
  69.         // delete partInfo if it was allocated off the heap
  70.         partInfo = childFacet->GetPartInfo(ev);
  71.         delete partInfo;
  72.         facet->RemoveFacet(ev, childFacet);
  73.     }
  74.     delete iter;
  75. }
  76.